//
//  SeekEquipmentTable.m
//  OperationPro
//
//  Created by yaxue wang on 2017/2/28.
//  Copyright © 2017年 展鸿科技. All rights reserved.
//

#import "SeekEquipmentTable.h"
#import "SeekEqipmetTableCell.h"
#import "SeekEquipmetModel.H"
@interface SeekEquipmentTable()


@end
@implementation SeekEquipmentTable

-(instancetype)initWithFrame:(CGRect)frame withInstUuid:(NSString*)instUuid
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor=BackColor;
        self.separatorStyle=UITableViewCellSeparatorStyleNone;
        self.showsVerticalScrollIndicator =NO;
        [self registerCell:[SeekEqipmetTableCell class] withModel:[SeekEquipmetModel class]];
        [self setTableActionType:CTableActionType_Push];
        self.perPageCount = 15;
        //死的
        [self setDataWithUrl:@"machine_queryPage" andParam:@{@"inst_uuid":instUuid}];
        [self setTableActionType:CTableActionType_Both];
        [self loadData];


     
    }
    
    return self;
    
}

- (void)relodTableWithDictionary:(NSMutableDictionary*)dictionary{
 
 
    [self setDataWithUrl:@"machine_queryPage" andParam:dictionary];
    [self refresh];

    
}
- (void)reloadData
{
    if(self.mainData.count==0)
    {
        self.tableHeaderView=[self headView];
        
    }else
    {
        self.tableHeaderView=nil;
    }
    
    [super reloadData];
}
- (UIView *)headView
{
    UIView *bgView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 200)];
    bgView.backgroundColor=BackColor;
    UIImage *logo = [UIImage imageNamed:@"Ico_home_noData"];
    UIImageView *logoView = [[UIImageView alloc] initWithFrame:CGRectMake((WindowWidth-logo.size.width)/2, 86, logo.size.width, logo.size.height)];
    logoView.image=logo;
    [bgView addSubview:logoView];
    
    UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(logoView.frame)+23, WindowWidth, 18)];
    lbl.text = @"没有相关内容";
    [bgView addSubview:lbl];
    lbl.textAlignment=NSTextAlignmentCenter;
    lbl.textColor = C(@"989898");
    [lbl setFont:F(16)];
    return bgView;
}


- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    SeekEqipmetTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil) {
        cell = [[SeekEqipmetTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    SeekEquipmetModel *model = [self.mainData objectAtIndex:indexPath.row];
    [cell setModel:model];
    return cell;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    return 44;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
    SeekEquipmetModel *model = [self.mainData objectAtIndex:indexPath.row];
    if (self.CCellSelectBack) {
        NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
        [dic setObject:model.S_uuid forKey:@"uuid"];
        self.CCellSelectBack(dic);
    }
}

@end
